#include <iostream>
#include <string>
using namespace std;
class Solution
{
public:
    int addDigits(int num)
    {
        string str = to_string(num);
        int next = 0;
        for (int i = 0; i < str.length(); i++)
        {
            next += str[i] - '0';
        }
        if (next < 10)
            return next;
        return addDigits(next);
    }
};
int main()
{
    Solution *s = new Solution();

    int ans = s->addDigits(38);
    cout << "hello world" << endl;
    cout << ans << endl;
    return 0;
}